use Thomson_2022_Antisocialist_Law_Data.dta, clear
set more off
set scheme plotplain

******************************
* Effects of Expulsion Dummy *
******************************
* Model 1.1 EXPULSION DUMMY SD VOTE SHARE
xtreg sdvote asl3 i.year, fe vce(cluster DISTRICT_N)
est store exp_sdvote1

* Model 1.3 EXPULSION DUMMY SD VOTE TOTAL
xtreg sdsum asl3 i.year, fe vce(cluster DISTRICT_N)
est store exp_sdtotal1

* Model 1.5 EXPULSION DUMMY TURNOUT
xtreg turnout asl3 i.year, fe vce(cluster DISTRICT_N)
est store exp_turnout1

* Model 1.2 EXPULSION DUMMY SD VOTE SHARE W CONTROLS
xtreg sdvote asl3 ///
int_inequality int_landgini int_agriculture ///
int_lightind ln_pop int_protestant i.year, fe vce(cluster DISTRICT_N)
est store exp_sdvote2

*Model 1.4 EXPULSION DUMMY SDSUM W CONTROLS
xtreg sdsum asl3 ///
int_inequality int_landgini int_agriculture ///
int_lightind ln_pop int_protestant i.year, fe vce(cluster DISTRICT_N)
est store exp_sdtotal2

*Model 1.6 EXPULSION DUMMY TURNOUT W CONTROLS
xtreg turnout asl3 ///
int_inequality int_landgini int_agriculture ///
int_lightind ln_pop int_protestant i.year, fe vce(cluster DISTRICT_N)
est store exp_turnout2

**** TABLE 2
esttab exp_sdvote1 exp_sdvote2 exp_sdtotal1 exp_sdtotal2 exp_turnout1 exp_turnout2, ///
keep(asl3 ///
int_inequality int_landgini int_agriculture ///
int_lightind ln_pop int_protestant) ///
order(asl3 ///
int_inequality int_landgini int_agriculture ///
int_lightind ln_pop int_protestant) ///
label b(2) scalar(N_g) nogaps compress se ///
mtitles("Vote %" "Vote %" "Vote #" "Vote #" "Turnout" "Turnout") ///
addnotes("Constituency FEs, year FEs, clustered standard errors.")


**********************************
* Effect of number of expulsions *
**********************************

* Model 2.1 EXPULSIONS COUNT SD VOTE SHARE
xtreg sdvote c.expulsion_count##c.expulsion_count ///
int_inequality int_landgini int_agriculture ///
int_lightind ln_pop int_protestant i.year, fe vce(cluster DISTRICT_N)
est store exp_count_sdvote1

* Figure 2: Effect of Expulsions Count
margins, at(expulsion_count=(0(1)10))
marginsplot, xlabel(0(1)10) ///
title("Model 2.1" "Vote %", size(large)) ///
ytitle("SPD Vote %") xsize(6) ysize(6) legend(pos(6) cols(2)) ///
plot1opts(recast(line)) ///
ci1opts(recast(rarea) color(%30))

* Model 2.2 EXPULSIONS COUNT SD VOTE TOTAL
xtreg sdsum c.expulsion_count##c.expulsion_count ///
int_inequality int_landgini int_agriculture ///
int_lightind ln_pop int_protestant i.year, fe vce(cluster DISTRICT_N)
est store exp_count_sdtotal1

*************************************
* Effect of expulsions through time *
*************************************

* Model 2.3 POST-EXPULSIONS VOTE SHARE
xtreg sdvote time5 time7 time8 ///
i.year, fe vce(cluster DISTRICT_N)
est store exp_time_sdvote1

* Model 2.4 POST-EXPULSIONS VOTE SHARE WITH CONTROLS
xtreg sdvote time5 time7 time8 ///
int_inequality int_landgini int_agriculture ///
int_lightind ln_pop int_protestant i.year, fe vce(cluster DISTRICT_N)
est store exp_time_sdvote2

* Model 2.6 PRE- AND POST-EXPULSIONS VOTE SHARE WITH CONTROLS
xtreg sdvote time4 time5 time7 time8 time9 time10 ///
int_inequality int_landgini int_agriculture ///
int_lightind ln_pop int_protestant i.year, fe vce(cluster DISTRICT_N)
est store exp_time_sdvote3

* Figure 2: Effects of Expulsions Through Time
coefplot, keep(time4 time5 time7 time8 time9 time10) vertical yline(0) ///
msymbol(Oh) msize(large) mcolor(black) mlwidth(medthick) ciopts(recast(rcap) lcolor(black) lwidth(medthick)) ///
xtitle("Election Timing vs Expulsion", yoffset(-2)) xlabel(1 "t-2" 2 "t-1" 3 "t+1" 4 "t+2" 5 "t+3" 6 "t+4") ///
ytitle("Effect on SPD Vote %") title("Model 2.5" "Vote %", size(large)) ///
graphregion(color(white) lwidth(large)) bgcolor(white) xsize(4) ysize(4)

* Model 2.5 POST-EXPULSIONS VOTE TOTAL WITH CONTROLS
xtreg sdsum time5 time7 time8 ///
int_inequality int_landgini int_agriculture ///
int_lightind ln_pop int_protestant i.year, fe vce(cluster DISTRICT_N)
est store exp_time_sdtotal1

*** TABLE 2
esttab exp_count_sdvote1 exp_count_sdtotal1 exp_time_sdvote1 exp_time_sdvote2 exp_time_sdtotal1 exp_time_sdvote3, ///
keep(expulsion_count c.expulsion_count#c.expulsion_count time4 time5 time7 time8 time9 time10) ///
order(expulsion_count c.expulsion_count#c.expulsion_count time4 time5 time7 time8 time9 time10) ///
label b(2) scalar(N_g) nogaps compress se ///
mtitles("Vote %" "Vote #" "Vote %" "Vote %" "Vote #" "Vote %") ///
addnotes("Constituency FEs, year FEs, clustered standard errors." ///
"All models except 2.3 include full set of controls.")


***************************
* Covariate Balance Tests *
***************************
xtreg sdvote asl3 i.year, fe vce(cluster DISTRICT_N)

xtreg int_agriculture asl3 i.year if e(sample), fe
est store cob_ag

xtreg int_inequality asl3 i.year if e(sample), fe
est store cob_ineq

xtreg ln_pop asl3 i.year if e(sample), fe
est store cob_pop

xtreg int_landgini asl3 i.year if e(sample), fe
est store cob_landgini

xtreg int_catholic asl3 i.year if e(sample), fe
est store cob_catholic

esttab cob_ag cob_ineq cob_pop cob_landgini cob_catholic, ///
keep(asl3) ///
label b(2) scalar(N_g) ///
mtitles("Agriculture" "Ineq" "Ln Pop" "Land Gini" "Catholic")
